Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not propagate_to_hidden RouteFocusChanged events #2416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

smmalis37
Copy link
Contributor

@smmalis37 smmalis37 commented Dec 1, 2024

This fixes a bug I've been having when trying to update https://github.com/smmalis37/sudoku_rust from Druid v0.7 to v0.8. To reproduce the bug:

  • Checkout the repo at commit ef1653522f06852fcd86f56a9b79c7fa526be239 (currently the tip of master)
  • Update Druid in Cargo.toml from this PR to v0.8
  • Run the app
  • Click on multiple boxes and type in them

On my system this results in bizarrely inconsistent behavior, where some boxes will accept text input, but other boxes won't, seemingly randomly. I've done a bunch of debugging and this PR is my conclusion.

The root of the problem seems to be that BuildFocusChain isn't routed to hidden widgets but RouteFocusChanged is. When combining this with an Either, I seem to get into a state where every RouteFocusChanged event gets routed to both sides of the Either, resulting in merge_up seeing the hidden child having child_state.update_focus_chain be true, which leads to a BuildFocusChain event getting sent, which doesn't go to the hidden side, meaning that side's update_focus_chain never gets cleared. This means we're rebuilding the focus chain in the middle of handling every focus change, which I imagine can cause weirdness and doesn't feel right to me.

Some spot checking of other areas in the code also makes me feel that this is the right thing to be doing. For example RouteDisabledChanged already handles resigning focus if it previously had it, so RouteFocusChanged still going to a newly disabled widget shouldn't be necessary I think.

Hidden widgets can't have focus, so they don't need to know about focus changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant